<?php
/**
 * Created by PhpStorm.
 * User: yunpeng
 * Date: 2019/1/8
 * Time: 15:01
 */
namespace App\Imports;

use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithBatchInserts;
use phpDocumentor\Reflection\Types\Integer;


class UsersImport implements ToModel
{
    /**
     * @param array $row
     *
     * @return User|null
     */
    public function model(array $row)
    {
        //dump($row);exit;
        if (!isset($row[0])) {
            return null;
        }

        return new User([
            'name'     => $row[0],
            'password' => Hash::make($row[1]),
            'phone'    => $row[2],
            'iden'     => $row[3],
            'img'      => 'images/8828afba76ef5fabc1215e882d1f6d1f.jpg'
        ]);
    }
}